package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.CmsMemberReport;
import com.macro.mall.portal.service.CmsMemberReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

/**
 * @author super
 * @title: CmsMemberReportController
 * @description: TODO
 * @date 2020/10/8 16:37
 */

@Slf4j
@RestController
@RequestMapping("report")
@Api(tags = "report", description = "反馈表(cms_member_report)")
public class CmsMemberReportController {

    @Autowired
    CmsMemberReportService cmsMemberReportService;

    @ApiOperation("添加")
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult save(Principal principal, @ApiParam(value = "请求报文") @RequestBody CmsMemberReport request) {
        try {
            if(principal==null){
                return CommonResult.unauthorized(null);
            }
            cmsMemberReportService.saveNotNull(request);
            return CommonResult.success(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CommonResult.failed();

    }
}
